package com.yunjing.elasticjob.elastic;

import com.dangdang.ddframe.job.executor.ShardingContexts;
import com.dangdang.ddframe.job.lite.api.listener.AbstractDistributeOnceElasticJobListener;
import lombok.extern.slf4j.Slf4j;


/**
 * @author zhiqi.shao
 * @Date 2018/6/15 8:45
 */
@Slf4j
public class ElasticJobListener extends AbstractDistributeOnceElasticJobListener {



    public ElasticJobListener(long startedTimeoutMilliseconds, long completedTimeoutMilliseconds) {
        super(startedTimeoutMilliseconds, completedTimeoutMilliseconds);
    }

    @Override
    public void doBeforeJobExecutedAtLastStarted(ShardingContexts shardingContexts) {
        log.info("before JobName:{},JobEventSamplingCount:{},JobParameter{},TaskId:{}",shardingContexts.getJobName(),shardingContexts.getJobEventSamplingCount(),shardingContexts.getJobParameter(),shardingContexts.getTaskId());
    }

    @Override
    public void doAfterJobExecutedAtLastCompleted(ShardingContexts shardingContexts) {
        //任务执行完成后更新状态为已执行
        log.info("end JobName:{},JobEventSamplingCount:{},JobParameter{},TaskId:{}",shardingContexts.getJobName(),shardingContexts.getJobEventSamplingCount(),shardingContexts.getJobParameter(),shardingContexts.getTaskId());

    }
}